home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 009 / 32clspat.arc / 32CLSPAT.TXT next >
Encoding:
Text File  |  1987-03-25  |  5.3 KB  |  161 lines

  1.                           A N S I . S Y S
  2.  
  3.  
  4.  
  5. There are two ways to set screen color from DOS without using one of
  6. the many memory resident programs available.  I don't like using the
  7. memory resident programs because they are inevitably incompatible
  8. with something.  Both of the 'normal' methods involve patching DOS. 
  9. The first involves patching COMMAND.COM (instructions given below),
  10. and the second involves patching ANSI.SYS.  If you have ansi.sys
  11. loaded, and you use the dos CLS command, the command is routed to
  12. ANSI.SYS, and not through COMMAND.COM.  That is why you must patch
  13. ANSI.SYS for color if you intend to use it at all.  Both of these
  14. methods are activated by the CLS command.  Merely type CLS, and the
  15. screen changes color to whatever you have set it at.  All further
  16. writes to the screen will be in those colors too.  I prefer to use
  17. ANSI.SYS, for reasons which I will expound upon further.  Many
  18. programs use ansi for output, and these programs will magically
  19. appear in color once you have loaded ansi.sys.  ANSI.SYS supports
  20. screen colors, and the colors you want are changeable at any time. 
  21. Merely include the proper 'escape' codes in your PROMPT command, and
  22. the screen colors will change appropriately.  To use ANSI.SYS,
  23. include the following line in your CONFIG.SYS file:
  24.  
  25. DEVICE=ANSIPACH.SYS
  26.  
  27. Notice that the file is called ANSIPACH.SYS, and not ANSI.SYS.  That
  28. is the name of the file I have included in this ARC library.  It is
  29. already patched, and to save myself typing, I am not going to bother
  30. going into the nitty gritty detail of what the patch is.  It does
  31. replace the ESC[=# command, the 'Set Mode' command as it is called. 
  32. Since no programs use this, and the dos MODE command does the same
  33. thing anyway, there should be no problem.  To have set the screen
  34. colors using ANSI.SYS, you should include the appropriate 'escape
  35. sequences' in your PROMPT command.  Here is an excerpt from the
  36. DOS-3.1 Technical Reference Manual:
  37.  
  38.  
  39.         Set Graphics Rendition (SGR)
  40.  
  41. ESC[#,...;#m        Sets the character attribute specified
  42.             by the parameters.  All following
  43.             characters have the attribute according
  44.             to the parameters until the next occurence
  45.             of SGR.
  46.  
  47. Parameter    Meaning
  48. ---------    -------
  49.   0        All attributes OFF (Normal Black on White)
  50.   1        Bold ON (high intensity)
  51.   4        Underscore ON (IBM Monochrome display only)
  52.   5        Blink ON
  53.   7        Reverse Video ON
  54.   8        Canceled ON (invisible text)
  55.   30        Black foreground
  56.   31        Red foreground
  57.   32        Green foreground
  58.   33        Yellow foreground
  59.   34        Blue foreground
  60.   35        Magenta foreground
  61.   36        Cyan foreground
  62.   37        White foreground
  63.   40        Black background
  64.   41        Red background
  65.   42        Green background
  66.   43        Brown background
  67.   44        Blue background
  68.   45        Magenta background
  69.   46        Cyan background
  70.   47        White background
  71.  
  72.  
  73. To set the colors using the DOS PROMPT command, just type the
  74. following command:
  75.  
  76. PROMPT $e[#;#m$g         - Where # is a number taken off of the above chart.
  77.  
  78. If you like to have the current directory displayed when you are at
  79. dos, add $p to the command like this:
  80.  
  81. PROMPT $e[#;#m$p$g
  82.  
  83. For example, supposing I want the current directory displayed, and I
  84. would like screen colors of white on blue, I would use the command:
  85.  
  86. PROMPT $e[37;44m$p$g
  87.  
  88. If I wanted yellow on blue I would type:
  89.  
  90. PROMPT $e[33;44m$p$g
  91.  
  92. REMEMBER:  For this to work, you must have ANSIPACH.SYS loaded.  To
  93. do this, include it in your CONFIG.SYS file.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.                           C O M M A N D . C O M
  102.  
  103.  
  104. Here is a patch for DOS 3.2 CLS (clear screen) command.  It will let
  105. you set the screen colors to whatever you wish, and it will also
  106. change the screen border color as well as the foreground and
  107. background text colors.  I would prefer you use the ansi.sys patch
  108. which I describe above, but if you don't want ansi.sys loaded, and
  109. you don't think you will ever change your mind about what colors you
  110. wish to have, then I guess patching command.com is alright.  I feel
  111. ansi.sys is more independent.  When you are making this patch, be sure to
  112. make it on a COPY of the COMMAND.COM file.  NEVER patch your original
  113. programs, you're just asking for trouble if you do.  In this patch
  114. you will need to know the hexadecimal codes for the different screen
  115. colors.  Here they are:
  116.  
  117. 0 - Black    8 - Gray
  118. 1 - Blue    9 - Light Blue
  119. 2 - Green    A - Light Green
  120. 3 - Cyan    B - Light Cyann
  121. 4 - Red        C - Light Red
  122. 5 - Magenta    D - Light Magenta
  123. 6 - Brown    E - Yellow
  124. 7 - White    F - Bright White
  125.  
  126. Patch your COMMAND.COM file by using the command - 
  127.  
  128. DEBUG COMMAND.COM
  129.  
  130. Type the following:
  131.  
  132. A 2818
  133. MOV AH,0B
  134. MOV BX,000<n>    - Where <n> is the color (from the color chart
  135. INT 10             above) of the screen border color you wish to use.
  136. XOR CX,CX       For example, MOV BX,0001 gives you a blue border. 
  137. MOV AH,0F
  138. INT 10
  139. MOV BL,BH
  140. MOV DL,AH
  141. MOV DH,18
  142. MOV AX,0600
  143. MOV BH,<b><f>    - Where <b> is the code for the background color you
  144. INT 10             want, and <f> is the color for the foreground.  
  145. MOV BH,BL          For example, MOV BH,17 would    give you white on blue
  146. MOV AH,02          text, and MOV BH,1E would give you yellow on blue text. 
  147. XOR DX,DX
  148. INT 10
  149. RET
  150. NOP
  151.                  - Press return on a blank line.
  152. W
  153. Q
  154.  
  155.  
  156. You are done patching DOS.  You will have to reboot to see your
  157. changes go into effect.
  158.  
  159.  
  160.  
  161.